package com.yhk.usercenter.exception;

import com.yhk.usercenter.common.ErrorCode;

/**
 * @version 1.0
 * @Author moresuo
 * @Date 2023/12/11 23:00
 * @注释 自定义异常类
 */
public class BusinessException extends RuntimeException {
    private final int code;
    private final String description;
    public BusinessException(String message,int code,String description){
        super(message);//异常信息交给RuntimeException去显示
        this.code=code;
        this.description=description;
    }
    public BusinessException(ErrorCode errorCode){
        super(errorCode.getMessage());
        this.code=errorCode.getCode();
        this.description=errorCode.getDescription();
    }
    public BusinessException(ErrorCode errorCode,String description){
        super(errorCode.getMessage());
        this.code=errorCode.getCode();
        this.description=description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
